package cn.codeartist.springboot.component.rocketmq;

import cn.codeartist.springboot.component.rocketmq.listener.RocketMQConsumerListener;
import cn.codeartist.springboot.component.rocketmq.proxy.RocketMQProducer;
import cn.codeartist.springboot.component.rocketmq.proxy.impl.DefaultRocketMQProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * RocketMQ组件自动配置
 *
 * @author 艾江南
 * @date 2020/8/11
 */
@Configuration
public class RocketMQAutoConfiguration {

    @Autowired
    private RocketMQProducer scrmRocketMQProducer;

    @Bean
    public RocketMQConsumerListener rocketMQConsumerListener() {
        return new RocketMQConsumerListener();
    }

    @Bean
    @Scope(BeanDefinition.SCOPE_PROTOTYPE)
    public DefaultRocketMQProducer defaultRocketMQProducer() {
        DefaultRocketMQProducer producer = new DefaultRocketMQProducer();
        //
        return producer;
    }

    @Bean
    public RocketMQProducer scrmRocketMQProducer() {
        DefaultRocketMQProducer producer = new DefaultRocketMQProducer();
        return producer;
    }
}
